package com.ruoyi.service.tourism.impl;

import com.ruoyi.mapper.tourism.HotelMapper;
import com.ruoyi.service.tourism.HotelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.UUID;

/**
 * @author zeo
 * @explain 文旅酒店模块
 * @date 2021/2/1 8:40
 */
@Service
public class HotelServiceImpl implements HotelService {

    @Autowired
    HotelMapper hotelMapper;

    @Override
    public List<Map<String, Object>> findHotelMonthList(Map map) {
        return hotelMapper.findHotelMonthList(map);
    }

    @Override
    public List<Map<String, Object>> findHotelDayList(Map map) {
        return hotelMapper.findHotelDayList(map);
    }

    @Override
    public int addHotel(Map map) {
        String uuid = UUID.randomUUID().toString().trim().replaceAll("-", "");
        map.put("foreignId", uuid);
        hotelMapper.addShare(map);
        return hotelMapper.addHotel(map);
    }

    @Override
    public int editHotel(Map map) {
        return hotelMapper.editHotel(map) + hotelMapper.editShare(map);
    }

    @Override
    public int remove(String ids) {
        String[] idSplit = ids.split(",");
        int num = 0;
        for (String id : idSplit) {
            num += hotelMapper.removeHotel(id);
            hotelMapper.removeShare(id);
        }
        return num;
    }

    @Override
    public Map findHotelById(String id) {
        return hotelMapper.findHotelById(id);
    }

    @Override
    public Map getLastDayData(Map map) {
        return hotelMapper.getLastDayData(map);
    }
}
